package com.carl.zlds.tool.exception;

import com.carl.zlds.tool.common.result.CodeMsg;

public class GlobalException extends RuntimeException {
    public static final int ERROR_SERVER = -1;
    public static final int ERROR_DATABASE = 1000;
    public static final int ERROR_PARAM_NOT_SET = 1001;
    public static final int ERROR_AUTH_FAIL = 1002;
    public static final int ERROR_WRONG_PARAM = 1003;
    public static final int ERROR_NOT_EXISTS = 1004;
    public static final int ERROR_EXISTS = 1005;
    public static final int ERROR_NOT_ALLOWED = 1006;
    public static final int ERROR_FILE_UPLOAD = 1008;
    public static final int ERROR_CREATE_PASSWORD = 1009;
    public static final int ERROR_REQUEST_METHOD_NOT_SUPPORTED = 1010;
    public static final int ERROR_VALIDATE_CODE = 1011;
    public static final int ERROR_SHIRO_NO_AUTH = 1012;
    private CodeMsg cm;

    public GlobalException(CodeMsg cm) {
        super(cm.toString());
        this.cm = cm;
    }

    public GlobalException(String msg) {
        this.cm = new CodeMsg(-1, msg);
    }

    public GlobalException(int code, String msg) {
        this.cm = new CodeMsg(code, msg);
    }

    public CodeMsg getCm() {
        return this.cm;
    }
}
